/**
 * @file e2_t2_q7.c
 * @date 2022-03-05
 * 
 * @copyright Copyright (c) 2022 cnzyx MIT Licence
 * 
 */

#include<stdio.h>
#include<stdlib.h>

float fun(float eps){
    float temp=1,fac=1,result=1;
    for(int i=1;temp>=eps;i++){
        fac=1;
        for(int j=1;j<=i;j++){
            fac*=j;
        }
        temp=1/fac;
        result+=temp;
    }
    return result;
}

int main(int argc, char const *argv[])
{
    //UTF-8
    system("chcp 65001");
    float in_num1,result;
    printf("请输入精度eps：");
    scanf("%f,",&in_num1);
    result=fun(in_num1);
    printf("结果：%f\n",result);
    
    //Pause console
    system("pause");
    return 0;
}
